define(['util'], function (Util) {
    function ViewModel(params) {
        var defaultParams = {
            prefix:undefined,
            suffix:undefined,
            fontSize:undefined,//sm md lg
            color:undefined,
            clickAble:false,
            formatter:undefined,
        };

        $.extend(defaultParams,params.field._columnCmp.params);


        this._style = {};
        this._css = Util.generateBindCss(defaultParams.css);
        this._event = defaultParams.clickAble?params.field._event:{};
        this._fieldValue = params.record[params.field.name]();

        if(defaultParams.formatter) this._fieldValue = defaultParams.formatter($.extend({value:this._fieldValue},params));
        if(defaultParams.prefix) this._fieldValue = '{0}{1}'.formatTpl(defaultParams.prefix,this._fieldValue);
        if(defaultParams.suffix) this._fieldValue = '{0}{1}'.formatTpl(this._fieldValue,defaultParams.suffix);
        if(defaultParams.fontSize) this._css['uc-font-size-{0}'.formatTpl(defaultParams.fontSize)] = true;
        if(this._event.click) this._style['cursor'] = 'pointer';

        if(defaultParams.color) {
            switch (typeof defaultParams.color) {
                case 'string':
                    this._style['color'] = defaultParams.color;
                    break;
                default:
                    this._style['color'] = defaultParams.color(params);
            }
        }

        this.field = {name:params.field.name};
        this.record = params.record;
    }

    return ViewModel;
});
